<template>
  <div class="h-full flex flex-col overflow-auto">
    <ReadCard
      ref="readCardRef"
      :page-info="patientState"
      business-type="门诊挂号"
      show-settlement-type
      class="mb-2"
      @read="onReadCardSuccess"
      @tab-change="onTabRadioChange"
      @change="onChangeCard"
    >
      <!--<template #selfCost>
        <a-card>
          <a-form ref="formRef" :model="registerState" class="flex justify-between form-style-flex">
            <div class="flex">
              <a-form-item name="brName" class="w-[260px] mr-3 !mb-0">
                <SelectTable
                  v-model:value="registerState.brName"
                  :search-params="{ stdate: registerState.dateRange?.[0], eddate: registerState.dateRange?.[1], type: '2' }"
                  type="门诊挂号患者列表"
                  placeholder="姓名/助记码/卡号/手机号/身份证号"
                  @select="onSelect"
                />
              </a-form-item>
              <a-form-item label="挂号时间" name="dateRange" class="!mb-0">
                <a-range-picker v-model:value="registerState.dateRange" format="YYYY-MM-DD" value-format="YYYY-MM-DD" />
              </a-form-item>
            </div>

            <div>
              <a-button style="margin: 0 8px" @click="onClickReset">重置</a-button>
              <a-button type="primary" @click="handleSearch">刷新</a-button>
            </div>
          </a-form>
        </a-card>
      </template> -->
      <template #rightBtn>
        <div class="flex items-center">
          <span class="font-bold mr-1 w-[60px]">医保结算</span>
          <a-switch v-model:checked="settlementType" class="mr-8" />
          <a-button @click="onReset">重置</a-button>
        </div>
      </template>
    </ReadCard>
    <div class="flex-1 overflow-hidden flex">
      <div class="w-3/5 h-full flex flex-col overflow-auto">
        <a-card class="flex-1 overflow-auto" :body-style="{ height: '100%', display: 'flex', flexDirection: 'column' }">
          <div class="flex flex-col overflow-hidden flex-1">
            <BaseTitle title="患者信息" class="!pr-0">
              <div :class="['flex-1', 'flex', systemConfig.isMatter ? 'justify-between' : 'justify-end']">
                <div class="relative">
                  <div v-if="systemConfig.isMust" class="absolute left-2 text-red-500">*</div>
                  <a-select v-if="systemConfig.isMatter" v-model:value="visitType" class="w-96 ml-5" placeholder="请选择就诊事项" allow-clear>
                    <a-select-option v-for="(item, index) in dictOutList" :key="index" :value="item.dictOutpMatterId">{{ item.matterName }}</a-select-option>
                  </a-select>
                  <a-button type="primary" class="mx-2" @click="onClickReadCard">读取身份证</a-button>
                </div>
                <a-radio-group v-model:value="isReservation" button-style="solid" @change="onReset(1)">
                  <a-radio-button value="0">非预约</a-radio-button>
                  <a-radio-button value="1">预约</a-radio-button>
                </a-radio-group>
              </div>
            </BaseTitle>
            <div class="overflow-auto">
              <PatientInfoForm
                ref="patientInfoForm"
                v-model:value="patientState"
                form-class="pr-1.5"
                item-class="w-1/3"
                :is-name-input="tabActiveKey !== '自费' && tabActiveKey !== '特殊人员'"
                :exclude-item="['收费标准']"
                :patient-type="isReservation === '0' ? '患者' : '预约患者'"
                @loaded="patientInfoLoading = false"
              />
            </div>
          </div>
          <div v-if="systemConfig.isHistoryList" class="mt-5">
            <!-- column-code="000768" -->
            <BaseTable
              bordered
              column-code="000283"
              :exclude-columns="systemConfig.isInterconnection ? [] : ['yqmc']"
              :loading="loading"
              :height="150"
              :scroll="{ x: 1500 }"
              :data-source="tableData"
              :pagination="false"
            >
              <template #bodyCell="{ column, index }">
                <template v-if="column.dataIndex == 'xh'">
                  {{ index + 1 }}
                </template>
              </template>
            </BaseTable>
          </div>
        </a-card>
      </div>
      <div class="ml-2 w-2/5 h-full overflow-auto flex flex-col">
        <a-card class="flex-1 overflow-auto">
          <BaseTitle title="挂号" class="">
            <!-- 收费标准 -->
            <SelectChargeStandard v-if="systemConfig.isChargeStandard" v-model:value="registerState.chargeStandardId" class="ml-9 flex-1" select-first />
          </BaseTitle>
          <div class="flex flex-wrap 2xl:mt-4 mt-1">
            <a-form-item label="类别" class="w-1/3" required>
              <SelectRegistType v-model:value="registerState.ghlbid" :disabled="!!registerState.empId" class="w-full" @change="onSelectCategory" />
            </a-form-item>
            <a-form-item label="科室" class="w-1/3 pl-2" required>
              <a-select
                v-model:value="registerState.ksdm"
                :disabled="!!registerState.empId"
                class="min-w-[160px]"
                placeholder="请选择"
                :options="departmentList"
                :field-names="{ label: 'ksmc', value: 'ksdm' }"
                @select="onSelectDepartment"
              />
            </a-form-item>
            <a-form-item class="w-1/3 pl-12">
              <a-radio-group v-model:value="registerState.czfz">
                <a-radio :value="0">初诊</a-radio>
                <a-radio :value="1">复诊</a-radio>
              </a-radio-group>
            </a-form-item>
          </div>
          <!-- 选择医生 -->
          <a-form-item label="医生" class="mb-1 w-1/3" :label-col="{ style: { width: '48px' } }">
            <a-input v-model:value="doctorSearchKey" placeholder="搜索医生" :disabled="doctorList.length === 0" />
          </a-form-item>
          <a-carousel arrows class="w-full mb-2" :dots="false" :infinite="false">
            <template #prevArrow>
              <LeftOutlined class="!left-4 !text-base !text-gray-400 !bg-slate-100 z-10 rounded" />
            </template>
            <template #nextArrow>
              <RightOutlined class="!right-4 !text-base !text-gray-400 !bg-slate-100 z-10 rounded" />
            </template>
            <div v-for="(doctorChunk, index) in doctorChunkList" :key="index">
              <!-- tag-width="w-1/5" -->
              <CheckTags v-model:value="registerState.empId" tag-key="empId" :data-source="doctorChunk" @select="onSelectDoctor">
                <template #renderItem="{ item }"> {{ item.empName }}{{ item?.numberQuantityLimit }}</template>
              </CheckTags>
            </div>
            <div v-if="doctorChunkList.length === 0" class="w-full h-12 text-disabled !flex items-center">暂无医生</div>
          </a-carousel>
          <div class="flex flex-wrap">
            <a-form-item label="费别" class="w-full cost-type" required :wrapper-col="{ style: { flex: '1' } }">
              <div class="max-h-20 overflow-auto">
                <CheckTags v-model:value="registerState.ghfbid" tag-key="ghfbid" tag-class="min-w-[180px]" :data-source="feeList" @select="onChangeFeeType">
                  <template #renderItem="{ item }"> {{ item.ghfb }}</template>
                </CheckTags>
              </div>
            </a-form-item>
            <a-form-item v-if="getSystemConfig('IS_DOCTOR_ASSISTANT') === '1' && systemConfig.isAssistance" label="医助" class="w-1/2">
              <SelectTable v-model:value="registerState.assistant1EmpName" type="员工" placeholder="请选择" @select="onSelectAssistant1" />
            </a-form-item>
            <div class="flex items-center">
              <a-form-item v-if="systemConfig.isMedicalCardFee" label="病历本费">
                <a-switch v-model:checked="registerState.blbf" />
              </a-form-item>
              <a-form-item v-if="systemConfig.isInfoCardFee" label="信息卡费" class="ml-4">
                <a-switch v-model:checked="registerState.xxkf" />
              </a-form-item>
            </div>
            <a-divider dashed class="mt-2 mb-4" />
            <a-form-item label="挂号备注" class="w-full mt-2">
              <a-textarea v-model:value="registerState.memo" :rows="3" placeholder="请输入" />
            </a-form-item>

            <!-- <a-divider dashed class="mt-2 mb-4" />
            <div class="flex w-full items-center">
              <a-form-item class="w-1/4 pr-4 text-right">
                <a-checkbox v-if="systemConfig.isInfoCardFee" v-model:checked="registerState.xxkf">信息卡费 </a-checkbox>
              </a-form-item>
              <a-form-item class="w-1/4">
                <a-checkbox v-if="systemConfig.isMedicalCardFee" v-model:checked="registerState.blbf">病历本费</a-checkbox>
              </a-form-item>
            </div> -->
          </div>
        </a-card>
        <div class="flex flex-col relative">
          <a-card v-if="tabActiveKey !== '自费'" class="mt-2">
            <BaseTitle title="医保结算" class="!mb-0">
              <a-button type="primary" size="small" :disabled="!isCompleted" @click="onClickSettlement()">预结算</a-button>
            </BaseTitle>
            <div class="flex justify-between flex-wrap mt-4">
              <div class="w-1/2 mb-2">
                <span class="inline-block w-32 text-right">医疗总金额: </span>
                <span class="text-base">￥{{ formatAmount(preSettlementInfo.outPocketAmountResponse?.ysje || 0) }}</span>
              </div>
              <div class="w-1/2 mb-2">
                <span class="inline-block w-32 text-right">账户余额: </span>
                <span class="text-base">￥{{ formatAmount(preSettlementInfo.outPocketAmountResponse?.zhye || 0) }}</span>
              </div>
              <div class="w-1/2 flex items-center">
                <span class="inline-block w-32 text-right">医保支付: </span>
                <span class="text-base">￥{{ formatAmount(preSettlementInfo.outPocketAmountResponse?.ybzf || 0) }}</span>
                <a-popover trigger="click">
                  <template #content>
                    <!-- <CHSPopover :data="preSettlementInfo.medicareAmountResponse" /> -->
                    <template v-if="readCardInfo.isgb">
                      <CHSPopover :data="preSettlementInfo.medicareAmountResponse" />
                    </template>
                    <template v-else>
                      <CHSWQPopover :data="preSettlementInfo.yb5AmountResponse" />
                    </template>
                  </template>
                  <a-button size="small" class="ml-2" shape="circle">
                    <span class="text-sm">?</span>
                  </a-button>
                </a-popover>
              </div>
              <div class="w-1/2">
                <span class="inline-block w-32 text-right">未贯标金额: </span>
                <span class="text-base">￥{{ formatAmount(preSettlementInfo.outPocketAmountResponse?.wgbje || 0) }}</span>
              </div>
            </div>
          </a-card>
          <a-card class="mt-2 flex-1" :body-style="{ display: 'flex', alignItems: 'end', height: '100%', flexDirection: 'row' }">
            <div class="text-right mr-2 w-full">
              <!-- <div class="my-2">
                  本次实收 <span class="text-3xl text-red-500 font-bold">￥{{ formatAmount(registerState.ssje) }}</span>
                </div> -->

              <div class="flex items-center justify-end mb-3">
                <div class="mr-8 flex items-center">
                  <span class="mr-2">打印票据</span>
                  <a-switch v-model:checked="isPrintReceipt" />
                </div>
                <div class="flex items-center">
                  本次应收 <span class="text-3xl text-red-500 font-bold">￥{{ formatAmount(registerState.ysje) }}</span>
                </div>
              </div>

              <a-button class="ml-2 w-28" size="large" :disabled="!patientState.brName" @click="savePatientInfo(true)">保存档案</a-button>
              <a-button class="ml-2 w-28" size="large" @click="onReset">重置</a-button>
              <!-- <a-button
                v-if="tabActiveKey !== '0001'"
                type="primary"
                class="ml-2 w-28"
                size="large"
                :loading="chargeLoading"
                :disabled="!isCompleted"
                @click="savePatientInfo(1)"
              >
                医保收费
              </a-button> -->
              <a-button type="primary" class="ml-2 w-28" size="large" :disabled="!isCompleted" @click="savePatientInfo()"> 收费 </a-button>
            </div>
          </a-card>
        </div>
      </div>
    </div>
    <ChargeModal v-model:open="chargeOpen" :br-id="patientState.brId" :business-data="{ ...registerState, ...preSettlementInfo }" @success="onCharge" />
    <ReservationModal v-model:open="reservationOpne" :reservation-list="reservationList" @select="onSelectReservation" />

    <!-- 账户查询五期 -->
    <!-- <AccountQueryFive v-model:open="accountQueryFiveOpen" :resource-data="accountQueryData" /> -->
  </div>
  <!-- <a-modal v-model:open="testModel" title="test msg">
    <p>{{ testModelInfo }}</p>
    <a-button @click="closeTestModal">最后一步</a-button>
  </a-modal> -->
</template>

<script setup>
import { computed, onMounted, ref, watch } from 'vue'
import { message } from 'ant-design-vue'
import { useRouter, useRoute } from 'vue-router'
import { chunk } from 'lodash-es'
import { LeftOutlined, RightOutlined } from '@ant-design/icons-vue'
import dayjs from 'dayjs'
import { post, get } from '@/utils/request'
import { formatAmount, getAgeUnit } from '@/utils/format'
import CheckTags from '@/components/CheckTags'
import { getSystemConfig } from '@/utils/systemConfig'
import cofirmModal from '@/utils/confirm'
import ChargeModal from '@/components/ChargeModal'
import SelectRegistType from '@/components/SelectRegistType'
import ReservationModal from './ReservationModal'

const router = useRouter()

const isPrintReceipt = ref(true)
const patientInfoLoading = ref(true)
const chargeOpen = ref(false)
const patientInfoForm = ref(null)

const readCardInfo = ref({
  ck: '',
  kh: '',
  med_type: undefined,
  bigIll: false,
  bigIllNum: undefined,
  indInjury: false,
  indInjuryNum: ''
})
const patientState = ref({})
const registerState = ref({ ghlbid: null, czfz: 0, xxkf: false, blbf: false }) // czfz: 0,
const isReservation = ref('0')
const tabActiveKey = ref('自费')
const settlementType = ref(true) //是否医保结算
const setbh = getSystemConfig('ORGNIZATION_CODE') //组织机构代码
const visitType = ref(undefined)
// const couponId = ref('') // 优惠券的id
// const couponPrice = ref('') // 抵用券金额
// const memberId = ref('') // 会员id
// const memberPrice = ref('') // 会员卡钱
const dictOutList = ref([])
const readCardRef = ref(null)
// const checkInsutypeName = ref({}) //选中的险种类别

watch(
  () => patientState.value?.brId,
  (val) => {
    registerState.value.czfz = patientState.value.czfz || registerState.value.czfz || 0
    registerState.value.cmemo2 = patientState.value?.cmemo2
    isReservation.value === '1' && patientState.value?.dictOutpMatterId && (visitType.value = patientState.value?.dictOutpMatterId)
    val ? getData() : (tableData.value = [])
    if (patientState.value.yylsh) {
      router.push({
        path: '/out-registration/register',
        query: { ...route.query, id: patientState.value.brId, status: '1' }
      })
      setTimeout(() => getPatientInfo(), 300)
    }
  }
)

const { loading, tableData, getData } = useTable({
  url: getSystemConfig('IS_HIS_CONNECTIVITY_PATIENT') === '1' ? '/outp/mzdj/getMedicalHistoryList' : '/outp/mzdj/getPatientHistoryRegistrationInformationList',
  formatParams: () => {
    return {
      brId: patientState.value?.brId,
      br_id: patientState.value?.brId,
      setbh: setbh
    }
  }
})

const onSelectCategory = (value) => {
  registerState.value.ghlb = value
  registerState.value.empId = ''
  registerState.value.empName = ''
  getDoctorList()
  getFeeList()
}

const onSelectDepartment = (select = {}) => {
  registerState.value.oldKsdm = select
  registerState.value.ksdms = [select]
  getDoctorList()
}
const onSelectDoctor = (_, select) => {
  if (systemConfig.value.defaultChargeMode === '1') {
    getPriceItem(select)
    if (Object.keys(select).length > 0) {
      feeList.value = [select]
    } else {
      getFeeList()
    }
  } else if (systemConfig.value.defaultChargeMode === '2') {
    if (Object.keys(select).length > 0) {
      getDetailData()
    } else {
      getFeeList()
    }
  }
}
const getDetailData = async () => {
  const { data, code } = await post('/operation/opex/getEmpGHFBRegistered', {
    empId: registerState.value?.empId,
    pageNum: 1,
    pageSize: 999
  })
  if (code === 0) {
    feeList.value = data
    data[0] && getPriceItem(data[0])
  }
}
const getPriceItem = (item) => {
  const ksdm = item.ksdm || registerState.value.oldKsdm
  registerState.value.ksdms = [ksdm]
  registerState.value.ksdm = ksdm
  registerState.value.zlfybh = item.zlfybh
  registerState.value.ghfybh = item.ghfybh
}
// 获取科室
const departmentList = ref([])
const getDepartmentList = async () => {
  const { code, data } = await post('/outp/mzdj/getDeptInfoList', { sfylks: '0' })
  if (code !== 0) return
  departmentList.value = data
  if (!registerState.value.ksdm && data.length > 0) {
    registerState.value.ksdm = departmentList.value[0]?.ksdm
    registerState.value.oldKsdm = departmentList.value[0]?.ksdm
    registerState.value.ksdms = [departmentList.value[0]?.ksdm]
  }
  getDoctorList()
}

//获取医生
const doctorList = ref([])
const doctorSearchKey = ref('')
const doctorChunkList = computed(() => {
  if (doctorSearchKey.value) {
    return chunk(
      doctorList.value.filter((item) => item.empName.includes(doctorSearchKey.value)),
      10
    )
  }
  return chunk(doctorList.value, 10)
})
const getDoctorList = async () => {
  doctorList.value = []
  const { code, data = [] } = await post('/outp/mzdj/getSchedulingDocterList', { ksdm: registerState.value.ksdm, ghlbid: registerState.value.ghlbid })
  if (code !== 0) return
  doctorList.value = data
  // doctorChunkList.value = chunk(doctorList.value, 10)

  // if (data.length === 1) {
  //   registerState.value.empId = data[0].empId
  //   onSelectDoctor('', data[0])
  // }
  if (patientState.value.empId) {
    const patientDoctor = data.find((item) => item.empId === patientState.value.empId)
    if (patientDoctor) {
      registerState.value.empId = patientDoctor.empId
      onSelectDoctor('', patientDoctor)
    }
  }
}

// 获取费别
const feeList = ref([])
const getFeeList = async () => {
  const { code, data } = await post('/outp/oupCharge/getRegisterFee', {
    empId: registerState.value.empId,
    ghlbid: registerState.value.ghlbid
  })
  if (code !== 0) return
  if (data && data.length > 0) {
    feeList.value = data
    registerState.value = { ...registerState.value, ...data[0] }
  }
}

const onChangeFeeType = (_, type) => {
  registerState.value = { ...registerState.value, ...type }
}

watch(
  [
    () => registerState.value.ghfybh,
    () => registerState.value.zlfybh,
    () => registerState.value.blbf,
    () => registerState.value.xxkf,
    () => registerState.value.chargeStandardId,
    () => registerState.value.ksdm,
    () => registerState.value.tcjsje
  ],
  () => {
    getReceivableMoney()
  }
)
// watch(
//   () => registerState.value.yhje,
//   () => getRealityMoney()
// )

// 选择优惠券
// const onSuccessCoupon = async (id, price, state) => {
//   if (state === 1) {
//     couponId.value = id
//     couponPrice.value = Number(price)
//   } else {
//     memberId.value = id
//     memberPrice.value = Number(price)
//   }
//   await getReceivableMoney()
// }

//计算应收
const getReceivableMoney = async () => {
  const { blbf, xxkf, chargeStandardId, ghfybh, ksdms, zlfybh } = registerState.value
  if (!ghfybh) {
    registerState.value.ysje = 0
    registerState.value.ssje = 0
    registerState.value.fbyh = 0
    return
  }
  const { code, data, msg } = await post('/outp/mzdj/registeredReceivableCalculations', {
    blbf, //病历本费
    xxkf, //信息卡费
    chargeStandardId: systemConfig.value.isChargeStandard ? chargeStandardId : '', //收费标准编号
    zlfybh, //诊疗费编号
    ghfybh, //挂号费编号
    ksdms //科室代码
  })
  if (code !== 0) return message.error(msg || '获取应收金额失败')
  registerState.value.ysje = data || 0
  // getRealityMoney()
}
//计算实收&分币
// const getRealityMoney = async () => {
//   const { code, data, msg } = await post('/outp/oupCharge/getPennyDiscount', {
//     ysje: registerState.value.ysje || 0, //应收金额
//     yhje: registerState.value.yhje || 0,
//     patientCouponsId: couponId.value, // 优惠券id
//     offsetAmount: couponPrice.value // 抵用券金额
//   })
//   if (code !== 0) return message.error(msg || '获取实收金额失败')
//   registerState.value.ssje = data.ssje || 0
//   registerState.value.fbyh = data.fbwc || 0
// }

// 打印挂号单
const onPrint = (jzbhs = [], pjhm = []) => {
  if (!isPrintReceipt.value) return
  if (registerState.value.ssje) {
    if (jzbhs.length > 0) {
      jzbhs.forEach(async (item, index) => {
        const { code, msg, data } = await post(systemConfig.value.isPrint, { jzbh: item, pjhm: pjhm[index] || null, sftfbs: 0 })
        if (code !== 0) return message.error(msg)
        window.openExe?.rpt(data) //调用winform打印
      })
    }
  } else {
    if (systemConfig.value.isBill) {
      if (jzbhs.length > 0) {
        jzbhs.forEach(async (item, index) => {
          const { code, msg, data } = await post(systemConfig.value.isPrint, { jzbh: item, pjhm: pjhm[index] || null, sftfbs: 0 })
          if (code !== 0) return message.error(msg)
          window.openExe?.rpt(data) //调用winform打印
        })
      }
    }
  }
}

// 判断是否是第一次挂号
const getIsFirstRegistration = async () => {
  if (systemConfig.value.isLabel) {
    const { code, data, msg } = await get('/common/patient/isFirstRegistration?br_id=' + patientState.value?.brId)
    if (code !== 0) return message.error(msg)
    if (data) {
      onPrintLabel()
    } else {
      onReset()
    }
  } else {
    onReset()
  }
}

// 打印客户标签
const onPrintLabel = async () => {
  const firstRegistration = dictOutList.value.find((item) => item.dictOutpMatterId === visitType.value)
  if (firstRegistration?.matterName === '手术初诊') {
    const labelNumber = getSystemConfig('PRINTING_LABELS_FOR_MEDICAL_MATTERS')
    if (Number(labelNumber)) {
      for (let i = 0; i < Number(labelNumber); i++) {
        const { code, msg, data } = await post('/outp/outPrint/getMedicalRecordLabelPrint', { brId: patientState.value?.brId })
        if (code !== 0) return message.error(msg)
        window.openExe?.rpt(data) //调用winform打印
      }
    }
  } else {
    const { code, msg, data } = await post('/outp/outPrint/getMedicalRecordLabelPrint', { brId: patientState.value?.brId })
    if (code !== 0) return message.error(msg)
    window.openExe?.rpt(data) //调用winform打印
  }
  await onReset()
}
const formatZeroMoney = async () => {
  const { code, data } = await post('/outp/oupCharge/getChargeTypeList')
  if (code !== 0) return
  const chargeData = {}
  if (data && data.length > 0) {
    data.forEach((item) => {
      chargeData[item.zffsdm] = chargeData[item.zffsdm] ? chargeData[item.zffsdm] : 0
    })
  }
  chargeData.change = 0
  chargeData.fbyh = 0
  chargeData.yhje = 0
  chargeData.ysje = '0.00'
  chargeData.ssje = '0.00'
  onCharge(chargeData)
}

const onReset = (activeState) => {
  registerState.value = { ghlbid: systemConfig.value.defaultCategoryId, czfz: 0, xxkf: false, blbf: false }
  registerState.value.ksdm = systemConfig.value.defaultDepartment
  registerState.value.oldKsdm = systemConfig.value.defaultDepartment
  registerState.value.ksdms = [systemConfig.value.defaultDepartment]
  tableData.value = []
  patientState.value = { brXb: '男' }
  preSettlementInfo.value = {}
  readCardInfo.value = {
    med_type: readCardInfo.value.med_type
  }
  activeState !== 1 && getFeeList()
  getDoctorList()
  patientInfoForm.value.getMedicalRule()
  visitType.value = getSystemConfig('OUTP_DEFAULT_VISIT_DESTINATION_CODE')
  readCardRef.value?.reset()
}

// 判断收费按钮
const isCompleted = computed(() => {
  const baseStatus =
    registerState.value.ksdm && patientState.value.brName && patientState.value.brAge && registerState.value.ghfybh && registerState.value.ghfbid
  return systemConfig.value.isCounselor ? baseStatus && patientState.value.brZxsName : baseStatus
})

const onSelectAssistant1 = (select) => {
  registerState.value.assistant1EmpId = select.empId
  registerState.value.assistant1EmpName = select.empName
}

watch(
  () => patientState.value.ghlbid,
  (val) => {
    onSelectDepartment(registerState.value.ksdm)
    if (val) {
      registerState.value.ghlbid = patientState.value.ghlbid
    } else {
      registerState.value.ghlbid = systemConfig.value.defaultCategoryId
    }
  }
)

const route = useRoute()
const dictMatterId = ref('') // 就诊事项id
//获取患者信息
const getPatientInfo = async () => {
  if (route.query.status === '1') {
    isReservation.value = '1'
  } else {
    isReservation.value = systemConfig.value?.isMake
  }
  dictMatterId.value = route.query?.dictOutpMatterId
  if (route.query.id) {
    const { code, data = {} } = await get('/common/patient/getPatientInfo?br_id=' + route.query.id)
    if (code !== 0) return message.error('获取患者信息失败')
    patientState.value = {
      ...patientState.value,
      ...data,
      brAge: getAgeUnit(data.brAge).brAge || 0
    } // yylsh: userInfo.patientInfo?.yylsh
    registerState.value.czfz = data.czfz || 0
    registerState.value.chargeStandardId = data.chargeStandardId
    registerState.value.ghlbid = data.ghlbid || systemConfig.value.defaultCategoryId
    patientState.value.jksy = 2
    if (data.yylsh) {
      registerState.value.ksdm = data.ksdm
      registerState.value.ksdms = [data.ksdm]
      registerState.value.memo = data.yymemo
      getDoctorList()
    }
  }
  if (route.query.id) {
    getFeeList()
  } else {
    watch(
      () => registerState.value.ghlbid,
      () => {
        getFeeList()
      }
    )
  }
}

// 获取就诊事项
const getDictOutList = async () => {
  const res = await post('/outp/mzdj/getDictOutpMatterNumberList')
  if (res.code !== 0) return message.error(res.msg)
  dictOutList.value = res.data
  visitType.value = getSystemConfig('OUTP_DEFAULT_VISIT_DESTINATION_CODE')
  dictMatterId.value && (visitType.value = dictMatterId.value)
}

const onTabRadioChange = async (key) => {
  router.push({
    path: '/out-registration/register',
    query: { ...route.query, type: key }
  })
  tabActiveKey.value = key
  onReset(1)
}

const onReadCardSuccess = async (info) => {
  patientState.value = {}
  readCardInfo.value.kh = info.ybkResonse?.kh
  readCardInfo.value = { ...info, ck: readCardInfo.value.ck, mdtrtCertNo: info.mdtrtCertNo, mdtrtCertType: info.mdtrtCertType, med_type: info.medType } || {}
  if (info.ybkResonse?.br_id) {
    const { code, data = {}, msg } = await get('/common/patient/getPatientInfo?br_id=' + info.ybkResonse?.br_id)
    if (code !== 0) return message.error(msg || '获取患者信息失败')
    patientState.value = {
      ...data,
      brBlkh: systemConfig.value.isConvertID ? data.brSfz : data.brBlkh, //国家医保病历卡号采用身份证号
      brAge: getAgeUnit(data.brAge).brAge || 0
    }
  } else {
    //没有病人信息 赋值
    getCardInfo(info)
    //搜索预约信息
    getReservationList(info.ybkResonse.xm)
  }
}
// 读取身份正证
const getCardInfo = async (resJson) => {
  if (!resJson.ybkResonse.sfzh) {
    patientState.value.brName = resJson.ybkResonse.xm
    patientState.value.brHkdz = resJson.baseinfo.txdz
    patientState.value.brGj = '中国'
    patientState.value.brMz = resJson.baseinfo.natyName
    patientInfoForm.value.getPinyin(resJson.ybkResonse.xm)
    return
  }
  // 根据身份证获取出生日期,年龄
  const { code: IDCode, data: IDData, msg: IDMsg } = await post('/common/util/getCsrq', { sfzhm: resJson.ybkResonse.sfzh })
  if (IDCode !== 0) return message.error(IDMsg || '身份证有误')
  patientState.value.brSfz = resJson.ybkResonse.sfzh
  patientState.value.brName = resJson.ybkResonse.xm
  patientState.value.brBtd = IDData.brBtd
  patientState.value.brAge = IDData.brAge
  patientState.value.brXb = IDData.brXb
  patientState.value.brHkdz = resJson.baseinfo.txdz
  patientState.value.brGj = '中国'
  patientState.value.brMz = resJson.baseinfo.natyName
  patientInfoForm.value.getPinyin(resJson.ybkResonse.xm)
}
const reservationList = ref([])
const reservationOpne = ref(false)
const getReservationList = async (name) => {
  const { data, code, msg } = await post('/outp/mzdj/getBookingList', {
    pyjm: name,
    yyzts: ['0'],
    ksdms: [],
    stdate: dayjs().format('YYYY-MM-DD'),
    eddate: dayjs().format('YYYY-MM-DD')
  })
  if (code !== 0) return message.error(msg || '获取预约信息失败')
  reservationList.value = data
  reservationOpne.value = reservationList.value.length > 0
}
const onSelectReservation = (select) => {
  patientState.value = { ...select, ...patientState.value }
  patientState.value.yylsh = ''
  patientState.value.empId = ''
  patientState.value.ghfbid = ''
  patientState.value.ghlbid = ''
  patientState.value.ksdm = ''
  patientState.value.ksdms = []
}
const onChangeCard = (info) => {
  readCardInfo.value = { ...readCardInfo.value, ...info }
}
const systemConfig = ref({})
onMounted(() => {
  systemConfig.value = {
    isInterconnection: getSystemConfig('IS_HIS_CONNECTIVITY_PATIENT') === '1', //是否打开互联互通
    isConvertID: getSystemConfig('NMI_OUTP_PATIENT_MEDICAL_RECORD_SN_INPUT_ID_NUMBER') === '1', //国家医保病历卡号采用身份证号
    isInfoCardFee: getSystemConfig('CHARGE_INFORMATION_CARD') === '1', //收取信息卡费
    isMedicalCardFee: getSystemConfig('CHARGE_MEDICAL_RECORD_BOOK') === '1', //收取病历本费
    isCoupon: getSystemConfig('ENABLE_REGISTER_DISCOUNT') === '1', //启用挂号优惠功能
    isDisposePackage: getSystemConfig('ENABLE_OUTP_REGISTER_CHARGE_PACKAGE') === '1', //门诊挂号允许添加处置套餐
    isMergeRegisterFee: getSystemConfig('IS_MERGE_REGISTRATION_FEE') === '1', //是否合并挂号费
    isChargeStandard: getSystemConfig('ENABLE_CHARGE_STANDARD_MODE') === '1', //收费标准
    defaultChargeMode: getSystemConfig('REGISTERED_FEE_MODEL'), //挂号收费模式
    defaultCategoryId: getSystemConfig('REGISTER_DEFAULT_CATEGORY_CODE'), //默认挂号类别编号
    defaultDepartment: getSystemConfig('REGISTER_DEFAULT_DEPT_CODE'), //默认挂号科室编号
    isCHS: getSystemConfig('IS_EXIST_MEDICAL_INSURANCE') === '1', //是否启用医保
    isHistoryList: getSystemConfig('REGISTER_FORM_SHOW_HISTORY') === '1', //是否显示历史记录1显示0不显示
    isMake: getSystemConfig('REGISTER_FORM_DEFAULT_PATIENT_PATH'), //0:非预约|| 1:预约
    isMatter: getSystemConfig('IS_OUTP_VISIT_DESTINATION') === '1', //是否启用启用门急诊就诊事项
    isAssistance: getSystemConfig('IS_SHOW_REGISTER_FORM_DOCTOR_ASSISTANT') === '1', // 是否在挂号登记页显示医助
    isLabel: getSystemConfig('IS_REGISTER_AUTO_PRINT_PATIENT_LABEL') === '1', // 0：不打印|1：自动打印
    isMust: getSystemConfig('OUTP_VISIT_DESTINATION_REQUIRED') === '1', // 就诊事项是否必填 0：不必填 1：必填
    isBill: getSystemConfig('PRINT_BILL_WHEN_FEE_IS_ZERO') === '1', // 费用为0时判断是否打印 0：不打印 1：打印
    isCounselor: getSystemConfig('IS_REQUIRED_CONSULTANT') === '1', //是否咨询师必填
    isPrint: getSystemConfig('REGISTRATION_FORM_PRINT_MODE') === '2' ? '/outp/outPrint/getRegistrationPrint' : '/outp/outPrint/getRegistrationBillPrint' // 0：通用|1：上海黑马|2：茗视光
  }
  registerState.value.ghlbid = systemConfig.value.defaultCategoryId
  registerState.value.ksdm = systemConfig.value.defaultDepartment
  registerState.value.oldKsdm = systemConfig.value.defaultDepartment
  registerState.value.ksdms = [systemConfig.value.defaultDepartment]
  getPatientInfo()
  getDepartmentList()
  getDictOutList()
  getFeeList()
})
/*
 * 2024-08-15 新增
 * 收费功能重构
 * 流程 0.读卡获取患者信息 1.选择挂号信息 2.保存患者信息 3.预结算 4.弹出收费界面（收费方式，优惠） 5.收费
 */
// const chargeLoading = ref(false)
// const chargeType = ref('')
const savePatientInfo = async (onlySave = false) => {
  if (systemConfig.value.isMust) {
    if (!visitType.value) {
      return message.error('请选择就诊事项')
    }
  }
  const idCard = patientState.value.brSfz
  if (patientState.value.brZjlx && patientState.value.brZjlx === '身份证') {
    if (idCard && idCard.length) {
      const { code: codeZjh, msg: msgZjh } = await post('/common/util/getCsrq', { sfzhm: idCard })
      if (codeZjh !== 0) {
        return message.error(msgZjh || '身份证有误')
      }
    }
  }
  if (patientState.value.isBrBlkh && !patientState.value.brBlkh) {
    return message.error('请填写病历号')
  }
  if (patientState.value.jksy !== 0) {
    patientState.value.jksy = patientState.value?.brId ? 2 : 1
  }
  // 按断年龄是否为0，
  if (patientState.value.brAge === '0') {
    const isAgeConfirm = await cofirmModal({ title: '提示', content: '当前患者年龄为0,请确认是否真实?' })
    if (!isAgeConfirm) {
      return
    }
  }
  // 判断咨询师是否必填
  if (systemConfig.value.isCounselor && !patientState.value.brZxsName) {
    return message.error('请选择咨询师')
  }

  // stateInfo && (chargeLoading.value = true)
  // if (stateInfo) {
  //   setTimeout(() => {
  //     chargeLoading.value = false
  //   }, 2000)
  // }
  const res = await post(
    '/common/patient/savePatientInfo',
    {
      baseinfo: readCardInfo.value.baseinfo,
      ybkResonse: readCardInfo.value.ybkResonse,
      ...patientState.value,
      brJzsx: visitType.value,
      brAge: getAgeUnit(patientState.value.brAge).brAge || 0
    },
    {
      loading: true
    }
  )
  patientState.value.brId = res.data
  if (onlySave) {
    if (res.code !== 0) return message.error(res.msg || '保存失败')
    message.success('保存成功')
    return
  }
  if (tabActiveKey.value === '特殊人员') {
    const { code, msg, data } = await post('/outp/oupCharge/obtainExpenseRetiredCadres', {
      brId: patientState.value.brId,
      obtainExpenseGhRequest: {
        ghfybh: registerState.value.ghfybh,
        zlfybh: registerState.value.zlfybh
      },
      retiredCadre: readCardInfo.value.retiredCadre,
      type: 'GH'
    })
    if (code !== 0) return message.error(msg || '保存失败')
    preSettlementInfo.value = {
      ysje: data?.ysje,
      outPocketAmountResponse: {
        ssje: data?.ssje,
        ybzf: data?.ybzf
      }
    }
    // preSettlementInfo.value.ysje = data?.ysje
    // preSettlementInfo.value.outPocketAmountResponse.ssje = data?.ssje
    // preSettlementInfo.value.outPocketAmountResponse.ybzf = data?.ybzf
  }
  //自费
  if (tabActiveKey.value === '自费' || tabActiveKey.value === '特殊人员' || !settlementType.value) {
    if (res.code === 0) {
      if (!registerState.value.ysje) {
        formatZeroMoney()
      } else {
        systemConfig.value.isMergeRegisterFee ? formatZeroMoney() : (chargeOpen.value = true)
      }
    } else {
      if (res.data) {
        const isConfirm = await cofirmModal({ title: '提示', content: res.msg })
        if (isConfirm) {
          patientState.value.jksy = 0
          savePatientInfo()
        }
      } else {
        message.error(res.msg)
      }
    }
    //医保
  } else {
    if (!readCardInfo.value.med_type) {
      return message.error('请选择医疗类别')
    }
    const resBrxx = await post('/outp/mzdj/doSaveYbBrxx', {
      ...readCardInfo.value,
      brId: patientState.value.brId
    })
    if (resBrxx.code !== 0) {
      return message.error(resBrxx.msg || '保存医保信息失败')
    }
    if (registerState.value.ysje === 0 || systemConfig.value.isMergeRegisterFee) {
      const settleResult = await onPreSettlement()
      settleResult && formatZeroMoney()
    } else {
      onPreSettlement(true)
    }
  }
}
const onClickSettlement = async () => {
  if (systemConfig.value.isMust) {
    if (!visitType.value) {
      return message.error('请选择就诊事项')
    }
  }
  const res = await post(
    '/common/patient/savePatientInfo',
    {
      baseinfo: readCardInfo.value.baseinfo,
      ybkResonse: readCardInfo.value.ybkResonse,
      ...patientState.value,
      brJzsx: visitType.value,
      brAge: getAgeUnit(patientState.value.brAge).brAge || 0
    },
    {
      loading: true
    }
  )
  if (res.code !== 0) return message.error(res.msg || '保存信息失败')
  patientState.value.brId = res.data
  if (!readCardInfo.value.med_type) {
    return message.error('请选择医疗类别')
  }
  const resBrxx = await post('/outp/mzdj/doSaveYbBrxx', {
    ...readCardInfo.value,
    brId: patientState.value.brId
  })
  if (resBrxx.code !== 0) {
    return message.error(resBrxx.msg || '保存医保信息失败')
  }
  onPreSettlement()
}
//预结算
const preSettlementInfo = ref({})
const onPreSettlement = async (isOpen = false) => {
  registerState.value.isChargeInformationcard = registerState.value.xxkf ? '1' : '0'
  registerState.value.isChargeMedicalbook = registerState.value.blbf ? '1' : '0'
  const { code, msg, data } = await post('/outp/mzdj/preSettlementRegisterInfo', {
    ...patientState.value,
    ...registerState.value,
    ghlbid: patientState.value.ghlbid ? patientState.value.ghlbid : registerState.value.ghlbid,
    dictOutpMatterId: visitType.value,
    miFlag: 0,
    czfz: registerState.value?.czfz,
    fbyh: registerState.value.fbyh,
    ybkh: readCardInfo.value.kh,
    insutype: registerState.value.insutype,
    healthCareRegisteredData: readCardInfo.value,
    mdtrtCertNo: readCardInfo.value.mdtrtCertNo,
    mdtrtCertType: readCardInfo.value.mdtrtCertType,
    zhbs: readCardInfo.value.isgb ? undefined : readCardInfo.value?.ybkResonse?.zhbs,
    insureStatus: 1
  })
  if (code !== 0) {
    message.error(msg || '预结算失败')
    return false
  }
  if (readCardInfo.value.isgb) {
    //国平
    chargeOpen.value = isOpen
    preSettlementInfo.value = data
    return true
  } else {
    //上海五期
    let result = window.openExe?.readGHQQ(data?.jsonStr)
    if (!window.openExe) {
      result =
        '{"response":{"czybm":"001","sysResv":"1234567887654321UeS6eS6UUSe6S6Ue6eUSUUe6SU66eeS6SUe6c0a8006f","recvTime":"0004089798fc01fd","bbh":"0001","msgid":"Y021010030020220628000830194","fhxx":"","jyqd":"10","xxlxm":"SH01","jyyzm":"","xzqhdm":"310000","jysj":"2022-06-28 12:06:14","jgdm":"Y0210100300","xxfhm":"P001","zdsbsbm":"","czyxm":"李倩雯","xxnr":{"fjdzhzfs":"0.00","jlc":"300003757604","zfdxjzfs":"0.00","tcdxjzfs":"0.00","totalexpense":"9.00","jfje":"0","zfdlnzhzfs":"0.00","curaccountpay":"0.00","tczfs":"0.00","curaccountamt":"0.00","fjdxjzfs":"3.15","fjzfs":"5.85","cardid":"N02423258","jmjsbz":"0","accountattr":"1000000000000000","tcdzhzfs":"0.00","cardtype":"1","fybjsfwfyze":"1.00","jssqxh":"H02Y021010030010430210628141799545","hisaccountamt":"0.00","ybjsfwfyze":"9.00","hisaccountpay":"0.00","personname":"吕琦华","personspectag":"0"}}}'
    }
    const res1 = await post('outp/mzdj/doCallbackAPi', {
      jsonStr: result,
      jzbh: data.jzbh
    })
    if (res1.code !== 0) {
      message.error(res1.msg || '挂号失败')
      return false
    }
    chargeOpen.value = isOpen
    preSettlementInfo.value = res1.data
    return true
  }
}
//收费
const onCharge = async (chargeData = {}) => {
  registerState.value.isChargeInformationcard = registerState.value.xxkf ? '1' : '0'
  registerState.value.isChargeMedicalbook = registerState.value.blbf ? '1' : '0'
  //自费
  if (tabActiveKey.value === '自费' || tabActiveKey.value === '特殊人员' || !settlementType.value) {
    const { code, msg, jzbhs, pjhm } = await post(
      '/outp/mzdj/doRegister',
      {
        ...patientState.value,
        ...registerState.value,
        ...chargeData,
        brAge: getAgeUnit(patientState.value.brAge).brAge || 0,
        ghlbid: patientState.value.ghlbid ? patientState.value.ghlbid : registerState.value.ghlbid,
        dictOutpMatterId: visitType.value,
        healthCareRegisteredData: readCardInfo.value, //医保信息
        retiredCadreType: readCardInfo.value?.retiredCadreType, // 类别
        retiredCadre: readCardInfo.value?.retiredCadre, // 退休干部
        miFlag: 0,
        czfz: registerState.value?.czfz
        // fbyh: registerState.value.fbyh,
        // vipno: memberId.value,
        // dyqzf: couponPrice.value, // 抵用券金额
        // dyqno: couponId.value // 抵用券id
      },
      {
        loading: true
      }
    )
    if (code !== 0) return message.error(msg || '挂号失败')
    message.success('挂号成功')
    getIsFirstRegistration()
    chargeOpen.value = false
    getDictOutList(1)
    if (systemConfig.value.isMergeRegisterFee) {
      onPrint(jzbhs)
    } else {
      onPrint(jzbhs, pjhm)
    }
  } else {
    //阜阳医保才会调壳验证密码
    let verRes = ''
    if (getSystemConfig('NMI_REGION_CODE') === '022' && registerState.value.insutype === '310' && tabActiveKey.value === '社保卡') {
      verRes = await window.openExe?.iVerifyPIN()
    }
    const chsParams = {
      ...patientState.value,
      ...registerState.value,
      ghlbid: patientState.value.ghlbid ? patientState.value.ghlbid : registerState.value.ghlbid,
      dictOutpMatterId: visitType.value,
      miFlag: 0,
      jzbh: preSettlementInfo.value.outPocketAmountResponse?.jzbh,
      pjhm: preSettlementInfo.value.outPocketAmountResponse?.pjhm,
      insureStatus: 1,
      ...chargeData,
      insutype: registerState.value.insutype,
      healthCareRegisteredData: readCardInfo.value, //读卡医保信息
      medicareSettlementInfo: {
        ...preSettlementInfo.value.outPocketAmountResponse,
        ...preSettlementInfo.value.medicareAmountResponse
      }, //预结算信息
      isgb: readCardInfo.value.isgb,
      acct_used_flag: '1',
      mmJson: verRes ? verRes : undefined
    }
    //医保
    const { code, msg, data, jzbhs, pjhm } = await post('/outp/mzdj/registerPaymentForScanZF', chsParams, { loading: true })
    if (code !== 0) return message.error(msg || '挂号失败')
    if (readCardInfo.value.isgb) {
      message.success('挂号成功')
      chargeOpen.value = false
      getIsFirstRegistration()
      getDictOutList(1)
      if (systemConfig.value.isMergeRegisterFee) {
        onPrint(jzbhs)
      } else {
        onPrint(jzbhs, pjhm)
      }
    } else {
      let result = window.openExe?.readGHQQ(data)
      if (!window.openExe) {
        result =
          '{"response":{"czybm":"001","sysResv":"1234567887654321UeS6eS6UUSe6S6Ue6eUSUUe6SU66eeS6SUe6c0a8006f","recvTime":"0004089798fc01fd","bbh":"0001","msgid":"Y021010030020220628000830195","fhxx":"","jyqd":"10","xxlxm":"SH02","jyyzm":"","xzqhdm":"310000","jysj":"2022-06-28 12:06:15","jgdm":"Y0210100300","xxfhm":"P001","zdsbsbm":"","czyxm":"李倩雯","xxnr":{"fjdzhzfs":"0.00","jlc":"300003757604","lsh":"2101010287593929","zfdxjzfs":"0.00","tcdxjzfs":"0.00","totalexpense":"9.00","jfje":"0.00","zfdlnzhzfs":"0.00","curaccountpay":"0.00","tczfs":"0.00","curaccountamt":"0.00","fjdxjzfs":"3.15","fjzfs":"5.85","jzdyh":"22062800000151858498","cardid":"N02423258","jmjsbz":"0","tcdzhzfs":"0.00","cardtype":"1","fybjsfwfyze":"1.00","jssqxh":"H02Y021010030010430210628141799545","hisaccountamt":"0.00","ybjsfwfyze":"9.00","hisaccountpay":"0.00"}}}'
      }
      const res1 = await post('outp/mzdj/doCallbackAPi', {
        jsonStr: result,
        jzbh: data.jzbh,
        registerRequest: chsParams
      })
      if (res1.code !== 0) return message.error(res1.msg || '挂号失败')
      message.success('挂号成功')
      chargeOpen.value = false
      getIsFirstRegistration()
      getDictOutList(1)
      if (systemConfig.value.isMergeRegisterFee) {
        onPrint(res1.jzbhs)
      } else {
        onPrint(res1.jzbhs, res1.pjhm)
      }
    }
  }
}

// 读取身份正证
const onClickReadCard = async () => {
  const res = window.openExe?.readIDCard() || '{}' //调用壳
  const resJson = JSON.parse(res)
  if (!resJson.sfz) return
  // const resJson = {
  //   sfz: '371421200210170046',
  //   name: '汪振11',
  //   btd: '1990-12-12',
  //   jtdz: '家庭地址xxxxxx',
  //   mz: '01'
  // }
  // 根据身份证获取出生日期,年龄
  const thisData = patientInfoForm.value.getData()
  const { code: IDCode, data: IDData, msg: IDMsg } = await post('/common/util/getCsrq', { sfzhm: resJson.sfz })
  if (IDCode !== 0) return message.error(IDMsg || '身份证有误')
  // 患者档案中查询此人信息
  if (!route.query.yylsh) {
    const { code, data } = await get('/common/patient/getPatientSfz?brSfz=' + resJson.sfz)
    if (code === 0) {
      patientState.value.brId && data.brId !== patientState.value.brId && onReset()
      patientState.value = { ...patientState.value, ...data, brJtdz: data.brJtdz || thisData.brJtdz, brMob: data.brMob || thisData.brMob }
    } else {
      onReset()
    }
  }
  patientState.value.brName = '读取中...'
  // 获取民族
  const { data: mzData } = await post('/common/masterData/getByDictCommonCode_dictItemCode', {
    dictCommonCode: 'naty',
    dictItemCode: resJson.mz
  })
  patientState.value.brSfz = resJson.sfz
  patientState.value.brName = resJson.name
  patientState.value.brBtd = IDData.brBtd
  patientState.value.brAge = IDData.brAge
  patientState.value.brXb = IDData.brXb
  if (!patientState.value.brHkdz) patientState.value.brHkdz = resJson.jtdz
  if (!patientState.value.brJtdz) {
    if (getSystemConfig('OUTP_REGISTER_AUTOFILL_FAMILY_ADDRESS') === '1') {
      patientState.value.brJtdz = patientState.value.brHkdz
    }
  }
  patientState.value.brGj = '中国'
  patientState.value.brMz = mzData.dictItemName
  patientInfoForm.value.getPinyin(resJson.name)
}
</script>
<style lang="less" scoped>
.border-heavy {
  border-color: var(--border-heavy-color);
}

:deep(.ant-radio-button-wrapper) {
  flex: 1;
  color: var(--primary-color);
  text-align: center;
  border-color: var(--primary-color);
  &::before {
    background-color: var(--primary-color);
  }
}
/* For demo */
:deep(.slick-slide) {
  padding-right: 50px;
  padding-left: 50px;
  overflow: hidden;
  text-align: center;
}
:deep(.slick-arrow:before) {
  display: none;
}
.cost-type {
  :deep(.ant-form-item-required) {
    padding-top: 7px;
  }
}
:deep(.ant-card-body) {
  display: flex;
  flex-direction: column;
}
</style>
